﻿using AutoMapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tauren.Business.Entity.Const;

namespace Tauren.Business.Mapper
{
    public class EmployeeProfile : Profile, ICommProfile
    {
        public EmployeeProfile()
        {
            InitProfile();
        }

        public void InitProfile()
        {
            CreateMap<Entity.Model.Employee, Entity.Output.Employee_OutPut>().AfterMap((data, viw) =>
            {
                viw.Dic_Creatdate = data.Creatdate is null ? "" : data.Creatdate.Value.ToString(GlobalConst.DATE_FORMAT_SECONDS);
                viw.Dic_Modifdate = data.Modifdate is null ? "" : data.Modifdate.Value.ToString(GlobalConst.DATE_FORMAT_SECONDS);
            });
            CreateMap<Entity.Input.Employee_input, Entity.Model.Employee>();
            CreateMap<Entity.Model.PageEployeeModel, Entity.Global.EmployeeListModel>().AfterMap((data, view) =>
            {
                view.CNName = data.CNName;
                view.EmpCode = data.EmpCode;
                view.EmpId = data.EmpId;
                view.ENName = data.ENName;
                view.OrganizationId = int.Parse(data.OrgId);
                view.PositionId = int.Parse(data.PositionId);
                view.RowNo = data.RowNo;
                view.UnitInfoId = data.UnitInfoId;
                view.OnPartTime = data.OnPartTime;
            });
            CreateMap<Entity.Global.GlobalModel, Entity.Output.GlobalModel_OutPut>();
            CreateMap<Entity.Global.PersonInfo, Entity.Output.PersonInfo_OutPut>();
            CreateMap<Entity.Input.PersonInfo_InPut, Entity.Global.PersonInfo >();
            CreateMap<Entity.Model.Parttimeinfo, Entity.Output.Parttimeinfo_OutPut>();
            CreateMap<Entity.Input.Parttimeinfo_InPut, Entity.Model.Parttimeinfo>();
        }
    }
}
